<?php
class Slider extends Doctrine_Record {
    public function setTableDefinition() {
        $this->setTableName('slider');
        $this->hasColumn('id', 'integer', 1, array('primary' => true, 'unsigned'=>true, 'autoincrement'=>true));
    }
    
    public function setUp(){
        $this->hasMany('Imagen as imagenes', array(
            'local' => 'id',
            'foreign' => 'id_slider'
        ));
    }
    
    public static function getInstance () {
        return Doctrine::getTable('slider')->find(1);
    }
    
    public static function images ($hidrateMode=false) {
        $hidrateMode = ($hidrateMode)?$hidrateMode:Doctrine::HYDRATE_ARRAY;
        return Doctrine_Query::create()
                ->select('i.*')
                ->from('Imagen i')
                ->orderBy('i.orden')
                ->innerJoin('i.slider s WITH s.id = 1')
                ->execute(array(), $hidrateMode);
    }
    
}
?>